﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WpfApplication1
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        /// <summary>
        /// 当前声音大小
        /// </summary>
        public int VoiceValue
        {
            get { return (int)GetValue(VoiceValueProperty); }
            set
            {
                SetValue(VoiceValueProperty, value);
                if (value <= 0)
                {
                    IsShowVoice = Visibility.Collapsed;
                    IsShowMute = Visibility.Visible;
                }
                else
                {
                    IsShowVoice = Visibility.Visible;
                    IsShowMute = Visibility.Collapsed;
                }
            }
        }
        /// <summary>
        /// 当前声音大小属性
        /// </summary>
        public static readonly DependencyProperty VoiceValueProperty =
            DependencyProperty.Register(
                "VoiceValue", typeof(int), typeof(MainWindow), new UIPropertyMetadata(10));

        /// <summary>
        /// 是否显示静音
        /// </summary>
        public Visibility IsShowMute
        {
            get { return (Visibility)GetValue(IsShowMuteProperty); }
            set { SetValue(IsShowMuteProperty, value); }
        }
        /// <summary>
        /// 是否显示静音属性
        /// </summary>
        public static readonly DependencyProperty IsShowMuteProperty =
            DependencyProperty.Register(
                "IsShowMute", typeof(Visibility), typeof(MainWindow), new UIPropertyMetadata(Visibility.Collapsed));

        /// <summary>
        /// 是否显示声音
        /// </summary>
        public Visibility IsShowVoice
        {
            get { return (Visibility)GetValue(IsShowVoiceProperty); }
            set { SetValue(IsShowVoiceProperty, value); }
        }
        /// <summary>
        /// 是否显示声音属性
        /// </summary>
        public static readonly DependencyProperty IsShowVoiceProperty =
            DependencyProperty.Register(
                "IsShowVoice", typeof(Visibility), typeof(MainWindow), new UIPropertyMetadata(Visibility.Visible));
        public MainWindow()
        {
            InitializeComponent();
        }

        private void MainWindow_MouseWheel(object sender, MouseWheelEventArgs e)
        {
            VoiceValue = VoiceValue + e.Delta / 100;
            if (VoiceValue <= 0)
                VoiceValue = 0;
            if (VoiceValue >= 100)
                VoiceValue = 100;
        }

        private void Path_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            Path p = sender as Path;
            if (p != null && p.Tag != null)
            {
                if (p.Tag.ToString() == "Normal")
                {
                    IsShowVoice = Visibility.Collapsed;
                    IsShowMute = Visibility.Visible;
                    VoiceValue = 0;
                }
                else
                {
                    IsShowVoice = Visibility.Visible;
                    IsShowMute = Visibility.Collapsed;
                    VoiceValue = 10;
                }
            }
        }
    }
}
